import operator

domains = {}

def domainmapper(domian):
    if domains.has_key(domain):
        return domains.get(domain)
    else:
        size = len(domains)
        domains[domain]= size+1
        return size+1
    
NUM_RECOMMEND = 5
   
def resultshash():
    session = []
    results_hash = {}
    probability_hash={}
    subdic = {}
    for domain in session:
        i=0
        while i<NUM_RECOMMEND:
            subdic = probability_hash.get(domain)
            candidate = max(subdic.iteritems(), key=operator.itemgetter(1))[0]
            if has_element(session, candidate)==0:
                if not results_hash.has_key(candidate):
                    results_hash[candidate]=int(subdic.get(candidate))
                else:
                    value = int(results_hash.get(candidate))
                    results_hash[candidate]=int(subdic.get(candidate))+value
                


def has_element(sessiondomains,test):
    for domain in sessiondomains:
        if domain == test:
            return 1
    return 0
        

